﻿<?php
   	include_once "../funciones.php";
    $con=conectar();
    $fallo=false;
   try {
        $con->beginTransaction();
        foreach($_POST as $OID => $valor){
           $sql="UPDATE MATERIALES SET MATERIAL_STOCK = '".$valor[1]."', MATERIAL_TOTAL = ".$valor[2]." WHERE OID_MAT = ".$OID."";
           echo $sql;
            $stmt = $con->prepare($sql);
           $stmt->execute();
           $stmt = $con->prepare("commit");
           $stmt->execute();
        }



   }catch(PDOException $e ) {
			echo "error: ".$e->GetMessage();
            $con->rollBack();
            header( 'Location: modificarMateriales.php?exito=2');
            $fallo=true;
	}


    if($fallo==false)
        header( 'Location: modificarMateriales.php?exito=1');



?>